import { legacy_createStore as createStore, combineReducers } from 'redux'
// 持久化工具
import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'

import { CollapseReducer } from '@/redux/reducers/CollapseReducer'
import { LoadingReducer } from '@/redux/reducers/LoadingReducer'

// 持久化配置
const persistConfig = {
  key: 'hzr',
  storage,
  whitelist: ['CollapseReducer'] // 白名单，只会存储配置了白名单的
}

const reducers = combineReducers({
  CollapseReducer,
  LoadingReducer
})

const persistedReducer = persistReducer(persistConfig, reducers)
const store = createStore(persistedReducer)
const persistor = persistStore(store)
export { store, persistor }